<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%String path = request.getContextPath(); %>
<%
String redirect = request.getHeader("referer");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
<link type="text/css" rel="stylesheet" href="css/login.css" />
<script src="<%=path %>/hotel/js/jquery-3.5.1.min.js" type="text/javascript"></script>
<script type="text/ecmascript" src="<%=path %>/hotel/login/js/MD5.js"></script>
<script src="<%=request.getContextPath() %>/hotel/layui/layui.js"></script>

<script type="text/javascript">
$(document).ready(function () {
	var height=$(document).height();
	$('.main').css('height',height);
})
//layui
/* function messageBox(mes){
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.msg(mes, {icon: 4});
    });
   } */

	
	function messageBox(mes){
	    layui.use('layer', function(){
	      var layer = layui.layer;
	      layer.msg(mes, {icon: 4});
	    });
	};
	   
	/* function re()
	{
		$("#pq").html("密码或者用户名错误")
	} */
		//给myform表单添加提交事件
		$("#userLogin").submit(check);
	/* 	$("#passWord").blur(re);  */
	
	/* var f=false;
	function re(){
		var use=
		$.ajax({
			url:"/hotelManagement/LoginServlet?action=userLgion",//要访问的servlet
			type:"post",//传输的（方式） 
			async:false,//线程（类似）
			data:"use="+userName,//传输的方式（）
			success:function(mes){
	} */
	
	function check()
	{
		
			
			var l=$("#passWord").val();
			
			var le = hex_md5(l);
		
			
			$("#b").val(le);
			
		
		
		return true;
	}
	
	

</script>
<style>
.asd{
margin: auto; 
z-index: 999;
width: 1200px;
/* float:right; */}

</style>
</head>

<body>
  <%
		String mes = request.getParameter("mes");
	%>
	<%
		if("1".equals(mes))
		{
	%>
			<div class="asd">
			<font color="red"  >用户名或者密码错误</font></div>
	<%
		}
	%>
<div class="main">
  <div class="main0">
     <div class="main_left">
        <img src="images/login-image-3.png" class="theimg"/>
        <img src="images/login-image-2.png" class="secimg"/>
        <img src="images/login-image-1.png" class="firimg"/>
     </div>
     
     <script type="text/javascript">
		$(function(){
			$("#sub").click(checkUser);
		})
		function checkUser(){
			var flag = check1();
			return flag;
		}
			function check1(){
				   check();
				   var username = $("#username").val();
				   var password = $("#b").val();
				   
				   var flag = false;
				   $.ajax({
					    url:"/hotelManagement/LoginServlet?action=userLgion",
					    type:"post",
					    async:false,
					    data:{username:username,password:password},
					    success:function(mes){
					  
					     if(mes=="0"){
						      messageBox("用户名或密码错误");
						      flag = false;
					     }else{
						      flag = true;
						      if("<%=redirect%>"!=null)
					     {
					       location.href="<%=redirect%>";
					     }
					     else
					     {
					       location.href="<%=path%>/IndexServlet";
					     }
					   }
					 }
				  })
				   
				  return flag;
			}
	 </script>
     <!-- cookie  action -->
     <%
     String username="";
     Cookie[]cks=request.getCookies();
     if(cks!=null)
     {
    	 for(Cookie c:cks){
    		 if(c.getName().equals("username")){
    			 username=c.getValue();
    			 break;
    		 }
    	 }
     }
     
     %>
     <!-- cookie end -->
      <!--form submit  -->
       
     	<div class="main_right">
     	 
	        <div class="main_r_up">
	            <img src="images/user.png" />
	            <div class="pp">登录</div>
	        </div>
        <div class="sub"><p><--还没有账号？登录在左边呦！</p>
        <a href="/hotelManagement/LoginServlet?action=transmissionRegis"><span class="blue">我在这！点我立即注册</span></a></div>
     
        <div class="txt">
        <form action="/hotelManagement/hotel/userCenter/order/order.jsp" method="post" id="userLogin">
            <span style="letter-spacing:8px;">用户名:</span>
            <input name="UsNm" value="<%=username %>" id="username" type="text" class="txtphone" placeholder="请输入注册手机号或用户名"/>
        </div>
        <div class="txt">
            <span style="letter-spacing:4px;">登录密码:</span>
            <input name="UsPs" id="passWord" type="password" class="txtphone" placeholder="请输入登录密码"/>
    		
        </div>
        <!-- <div class="txt">
            <span style=" float:left;letter-spacing:8px;">验证码:</span>
            <input name="" type="text" class="txtyzm" placeholder="请输入页面验证码"/>
            <img src="images/yanzhengma.png" class="yzmimg"/>
        </div> -->
         <input type="hidden" name="userpass" id="b" >
         
     
  
        <div class="xieyi">
            <input name="" type="checkbox" value="" checked="checked"/>
            记住我 <a href="password.jsp"><span class="blue" style=" padding-left:130px; cursor:pointer">忘记密码?</span></a>
        </div>
        <input class="xiayibu" id="sub" type="button" value="登录"/>
     </form>
     </div>
      
       <!-- end -->
  </div>
 
</div>
  
</body>
</html>
